using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Box2DCollider : BaseCollider
{
    public float width = 1;
    public float height = 1;

    public override bool OverlapPoint(Vector3 point)
    {
        if (point.x < transform.position.x - width / 2) return false;
        if (point.y < transform.position.y - height / 2) return false;
        if (point.x > transform.position.x + width / 2) return false;
        if (point.y > transform.position.y + height / 2) return false;
        return true;
    }

    private void OnDrawGizmos()
    {
        var pos1 = transform.position + new Vector3(width / 2, height / 2);
        var pos2 = transform.position + new Vector3(width / 2, -height / 2);
        var pos3 = transform.position + new Vector3(-width / 2, -height / 2);
        var pos4 = transform.position + new Vector3(-width / 2, height / 2);
        Gizmos.color = Color.green;
        Gizmos.DrawLine(pos1, pos2);
        Gizmos.DrawLine(pos2, pos3);
        Gizmos.DrawLine(pos3, pos4);
        Gizmos.DrawLine(pos4, pos1);
    }
}
